#pragma strict

var AAText : TextMesh;
var curAA : String;
var selectedAA : int;
var buttonColorTo : Color32;
var buttonColorFrom : Color32;
var colorSpeed : float;

function Start(){

	buttonColorTo = Color32(246,255,0,0);
	buttonColorFrom = Color32(150,150,150,0);	
	colorSpeed = 20;
	
	renderer.material.SetColor("_Color", buttonColorFrom);

}

function Update(){

	if(selectedAA == 0){
		AAText.GetComponent(TextMesh).text = "Anti-Aliasing: Off";
	} else {
		AAText.GetComponent(TextMesh).text = "Anti-Aliasing: "+selectedAA+"x MSAA";
	}

}

function OnMouseEnter() {

	iTween.ColorTo(gameObject, buttonColorTo, colorSpeed * Time.deltaTime);

}

function OnMouseExit() {

	iTween.ColorTo(gameObject, buttonColorFrom, colorSpeed * Time.deltaTime);

}

function OnMouseDown() {

	if(selectedAA == 16){
		selectedAA = 0;
	} else if(selectedAA == 8){
		selectedAA += 8;
	} else if(selectedAA == 4){
		selectedAA += 4;
	} else {
		selectedAA += 2;
	}
	
	QualitySettings.antiAliasing = selectedAA;

}